/**
 * *************************************
 * Copyright(c)2016 Dingdang Yixia 
 * All Rights Reserved.
 *
 * @File: WdgjCouldServer.java
 * @Package: com.wdgj.sdk.config
 * @Description:
 * 
 * @Version: V1.0
 * @Author: Yidong.Xiang
 * @Date: 2018年9月10日 下午5:42:50
 * 
 * *************************************
 */
package com.wdgj.sdk.config;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @ClassName: WdgjCouldServer.java
 * @Module: 
 * @Description: 
 * 
 * @author: Yidong.Xiang
 * @date: 2018年9月10日 下午5:42:50
 * 
 */
public class WdgjCouldServer {
	private final static String filePath = "/META-INF/wdgjcloud.properties";
	private static Properties prop;
	private static WdgjCouldServer instance;
	
	public static WdgjCouldServer getInstance()
	{
		if(instance==null)
			instance = new WdgjCouldServer();
		return instance;
	}
	private WdgjCouldServer() {
		reload();
	}
	private static void reload() {
		InputStream inS = null;
		try {
			// 读取属性文件 conf.properties 得到输入流
			inS = WdgjCouldServer.class.getResourceAsStream(filePath);
			if (inS == null)
				inS = new BufferedInputStream(new FileInputStream(filePath));
			
			if(prop==null)
				prop = new Properties();
			prop.load(inS);
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			try {
				inS.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	public String getValue(String key)
	{
		if(prop.containsKey(key))
			return prop.getProperty(key).trim();
		return "key not exist";
	}
//	public static void main(String[] args) {
//		
//		String value = WdgjOpenApi.getInstance().getValue("wdgj.url");
//		System.out.println(value);
//	}
}
